package com.elong.android.specialhouse.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.elong.android.specialhouse.AppConstants;
import com.elong.android.specialhouse.IConfig;
import com.elong.android.specialhouse.utils.CalendarUtils;
import com.elong.android.specialhouse.utils.DateTimeUtils;

import java.io.Serializable;
import java.util.Calendar;
import java.util.List;


public class ApartmentSearchParam implements Serializable{
	
	// 城市
	public String CityName;
	
	// 城市ID
	public String CityID;
	
	// 价格上限
	public int HighestPrice;
	
	//价格下限
	public int LowestPrice;
	
	//行政区、商圈或景区ID
	public String AreaId;
	
	//行政区或景区类型 1:行政区 2:商圈 3：景区
	public int AreaType;
	
	//行政区、商圈或景区
	public String AreaName;
	
	//半径
	public int Radius;
	
	//入住日期
	public Calendar CheckInDate;
	
	//离店日期
	public Calendar CheckOutDate;
	
	//排序方式
	public int OrderBy;	
	
	//是否使用poi搜索
	public boolean IsPosition;
	
	//经度
	public double Longitude;
	
	//纬度
	public double Latitude;
	
	//每页数量
	public int PageSize =15;
	
	//页索引导
	public int PageIndex;
	
	//会员卡号
	public String UserId;
	
	//会员等级
	public int MemberLevel;
	
	//智能搜索关键词（用于All In One Search）
	public String IntelligentSearchText;
	
	//出租类型
	public List<Integer> RentalType;

	//床数
	public short NumberOfBeds = 0;//0表示不限
	
	//房间可入住人数
	public short NumberOfPeople = 1;//筛选逻辑是人数>=1
	
	public int ImageSize;
	
	
	public ApartmentSearchParam() {
		CheckInDate = CalendarUtils.getCalendarInstance();
		CheckOutDate = CalendarUtils.getCalendarInstance();
		CheckOutDate.add(Calendar.DAY_OF_MONTH, AppConstants.DEFAULT_CHECKIN_CHECKOUT_DAYS);
	}
	
	@JSONField(name= "CityName")
	public String getCityName() {
		return CityName;
	}
	
	@JSONField(name= "CityName")
	public void setCityName(String cityName) {
		CityName = cityName;
	}
	
	@JSONField(name= "CityID")
	public String getCityID() {
		return CityID;
	}
	
	@JSONField(name= "CityID")
	public void setCityID(String cityID) {
		CityID = cityID;
	}
	
	@JSONField(name= "HighestPrice")
	public int getHighestPrice() {
		return HighestPrice;
	}
	
	@JSONField(name= "HighestPrice")
	public void setHighestPrice(int highestPrice) {
		HighestPrice = highestPrice;
	}
	
	@JSONField(name= "LowestPrice")
	public int getLowestPrice() {
		return LowestPrice;
	}
	@JSONField(name= "LowestPrice")
	public void setLowestPrice(int lowestPrice) {
		LowestPrice = lowestPrice;
	}
	
	@JSONField(name= "AreaId")
	public String getAreaId() {
		return AreaId;
	}
	
	@JSONField(name= "AreaId")
	public void setAreaId(String areaId) {
		AreaId = areaId;
	}
	
	@JSONField(name= "AreaType")
	public int getAreaType() {
		return AreaType;
	}
	
	@JSONField(name= "AreaType")
	public void setAreaType(int areaType) {
		AreaType = areaType;
	}
	
	@JSONField(name= "AreaName")
	public String getAreaName() {
		return AreaName;
	}
	
	@JSONField(name= "AreaName")
	public void setAreaName(String areaName) {
		AreaName = areaName;
	}
	
	@JSONField(name= "Radius")
	public int getRadius() {
		return Radius;
	}
	
	@JSONField(name= "Radius")
	public void setRadius(int radius) {
		Radius = radius;
	}
	
	@JSONField(name = "CheckInDate")
	public String getCheckInDate() {
		if (CheckInDate == null) {
			CheckInDate = CalendarUtils.getCalendarInstance();
		}
		return DateTimeUtils.formatCalendarToDateString(CheckInDate);
	}
	
	@JSONField(name = "CheckInDate")
	public void setCheckInDate(Calendar checkInDate) {
		CheckInDate = checkInDate;
	}
	
	@JSONField(name = "CheckOutDate")
	public String getCheckOutDate() {
		if (CheckOutDate == null) {
			CheckOutDate = CalendarUtils.getCalendarInstance();
			CheckOutDate.add(Calendar.DAY_OF_MONTH, IConfig.APARTMENT_CHECKIN_CHECKOUT_DAYS);
		}
		return DateTimeUtils.formatCalendarToDateString(CheckOutDate);
	}
	@JSONField(name = "CheckOutDate")
	public void setCheckOutDate(Calendar checkOutDate) {
		CheckOutDate = checkOutDate;
	}
	
	@JSONField(name= "OrderBy")
	public int getOrderBy() {
		return OrderBy;
	}
	
	@JSONField(name= "OrderBy")
	public void setOrderBy(int orderBy) {
		OrderBy = orderBy;
	}
	
	@JSONField(name= "IsPosition")
	public boolean isIsPosition() {
		return IsPosition;
	}
	
	@JSONField(name= "IsPosition")
	public void setIsPosition(boolean isPosition) {
		IsPosition = isPosition;
	}
	
	@JSONField(name= "Longitude")
	public double getLongitude() {
		return Longitude;
	}
	
	@JSONField(name= "Longitude")
	public void setLongitude(double longitude) {
		Longitude = longitude;
	}
	
	@JSONField(name= "Latitude")
	public double getLatitude() {
		return Latitude;
	}
	
	@JSONField(name= "Latitude")
	public void setLatitude(double latitude) {
		Latitude = latitude;
	}
	
	@JSONField(name= "PageSize")
	public int getPageSize() {
		return PageSize;
	}
	
	@JSONField(name= "PageSize")
	public void setPageSize(int pageSize) {
		PageSize = pageSize;
	}
	
	@JSONField(name= "PageIndex")
	public int getPageIndex() {
		return PageIndex;
	}
	
	@JSONField(name= "PageIndex")
	public void setPageIndex(int pageIndex) {
		PageIndex = pageIndex;
	}
	
	@JSONField(name= "UserId")
	public String getUserId() {
		return UserId;
	}
	
	@JSONField(name= "UserId")
	public void setUserId(String UserId) {
		UserId = UserId;
	}
	
	@JSONField(name= "MemberLevel")
	public int getMemberLevel() {
		return MemberLevel;
	}
	
	@JSONField(name= "MemberLevel")
	public void setMemberLevel(int memberLevel) {
		MemberLevel = memberLevel;
	}
	
	@JSONField(name= "IntelligentSearchText")
	public String getIntelligentSearchText() {
		return IntelligentSearchText;
	}
	
	@JSONField(name= "IntelligentSearchText")
	public void setIntelligentSearchText(String intelligentSearchText) {
		IntelligentSearchText = intelligentSearchText;
	}
	@JSONField(name= "RentalType")
	public List<Integer> getRentalType() {
		return RentalType;
	}
	
	@JSONField(name= "RentalType")
	public void setRentalType(List<Integer> rentalType) {
		RentalType = rentalType;
	}
	
	@JSONField(name= "NumberOfBeds")
	public short getNumberOfBeds() {
		return NumberOfBeds;
	}
	
	@JSONField(name= "NumberOfBeds")
	public void setNumberOfBeds(short numberOfBeds) {
		NumberOfBeds = numberOfBeds;
	}
	
	@JSONField(name= "NumberOfPeople")
	public short getNumberOfPeople() {
		return NumberOfPeople;
	}
	@JSONField(name= "NumberOfPeople")
	public void setNumberOfPeople(short numberOfPeople) {
		NumberOfPeople = numberOfPeople;
	}
	
	@JSONField(name= "ImageSize")
	public int getImageSize() {
		return ImageSize;
	}
	
	@JSONField(name= "ImageSize")
	public void setImageSize(int imageSize) {
		ImageSize = imageSize;
	}
	
	@JSONField(serialize = false)
	public void setFilterCondition(FilterCondition filterCondition){
		HighestPrice = filterCondition.getHighestPrice();
		if(HighestPrice > 1000){
			HighestPrice = 0;
		}
		LowestPrice= filterCondition.getLowestPrice();
		NumberOfPeople =filterCondition.getNumberOfPeople();
		NumberOfBeds =filterCondition.getNumberOfBeds();
		RentalType =filterCondition.getRentalType();
		
	}
	@JSONField(serialize = false)
	public void clearFilterCondition() {
		HighestPrice=0;
		LowestPrice=0;
		NumberOfPeople=1;
		NumberOfBeds=0;
		if(RentalType !=null){
			RentalType.clear();
		}
	}
	@JSONField(serialize = false)
	public void setKeywordPara(ApartmentKeyword m_keyWordData) {
		//根据suggest数据类型（1:行政区 2:商圈 3:景区 4:个人房源）设置参数
		switch (m_keyWordData.getType()) {
			case ApartmentKeyword.TYPE_DISTRICT: //行政区
				AreaName = m_keyWordData.getName();
				AreaId = m_keyWordData.getId();
				AreaType = ApartmentKeyword.TYPE_DISTRICT;
				IntelligentSearchText = "";
				IsPosition = false;
				Latitude = 0;
				Longitude = 0;
				break;
			case ApartmentKeyword.TYPE_COMMERCIAL:// 商圈
				AreaName = m_keyWordData.getName();
				AreaId = m_keyWordData.getId();
				AreaType = ApartmentKeyword.TYPE_COMMERCIAL;
				IntelligentSearchText = "";
				IsPosition = false;
				Latitude = 0;
				Longitude = 0;
				break;
			case ApartmentKeyword.TYPE_SCRNICSPOT:// 景区
				AreaName = m_keyWordData.getName();
				AreaId = m_keyWordData.getId();
				AreaType = ApartmentKeyword.TYPE_SCRNICSPOT;
				IntelligentSearchText = "";
				IsPosition = false;
				Latitude = 0;
				Longitude = 0;
				break;
			case ApartmentKeyword.TYPE_APARTMENT:// 个人房源
				AreaName = m_keyWordData.getName();
				AreaId = m_keyWordData.getId();
				AreaType = ApartmentKeyword.TYPE_APARTMENT;
				IntelligentSearchText = m_keyWordData.getName();// 关键词智能搜索
				Latitude = 0;
				Longitude = 0;
				IsPosition = false;
				break;
			case ApartmentKeyword.TYPE_UNKNOWN:// 用户自定义内容搜索
				IntelligentSearchText = m_keyWordData.getName();// 关键词智能搜索
				AreaName = "";
				AreaId = "";
				AreaType = 0;
				Latitude = 0;
				Longitude = 0;
				IsPosition = false;
				break;
		}
	}
}
